<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Fillform Class
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Pager
 * @author		vincent.wei
 */
class Fillform {

	var $id = 0;
	var $cateid = 0;
	
	var $idCard;
	var $passport;
	var $rTablePdf;
	
	var $CI;

	/**
	 * Constructor
	 *
	 * @access	public
	 * @param	array	initialization parameters
	 */
	public function __construct($params = array())
	{
		if (count($params) > 0)
		{
			$this->initialize($params);
		}else{
			die("calss Fillfrom params init False!");
		}

		// Determine the current page number.
		$this->CI =& get_instance();
		
		$this->initfunc();
		
		log_message('debug', "Fillform Class Initialized");
	}

	// --------------------------------------------------------------------

	/**
	 * Initialize Preferences
	 *
	 * @access	public
	 * @param	array	initialization parameters
	 * @return	void
	 */
	function initialize($params = array())
	{
		if (count($params) > 0)
		{
			foreach ($params as $key => $val)
			{
				if (isset($this->$key))
				{
					$this->$key = $val;
				}
			}
		}
	}
	
	// --------------------------------------------------------------------	
	private function initfunc(){
		if (empty($this->id)) die("calss Fillfrom func init False!");
		
		$this->CI->config->load('my_options', TRUE);
		$this->CI->load->model('R_Table_Pdf_Model','',TRUE);
		$this->CI->load->model('Archive_Idcard_Model','',TRUE);
		$this->CI->load->model('Archive_Passport_Model','',TRUE);
		$this->idCard = $this->CI->Archive_Idcard_Model->get_one($this->id);
		$this->passport = $this->CI->Archive_Passport_Model->get_one($this->id);
		$this->rTablePdf = $this->CI->R_Table_Pdf_Model->get_all();
	}
	
	public function getIdCard(){
		//add passport info;
		$this->idCard->birth_place = @$this->passport->place;
		$this->idCard->travel_document_num = @$this->passport->passport_no;
		$this->idCard->travel_document_type = @$this->passport->passport_type;
		$this->idCard->travel_document_issue_place = @$this->passport->issue_place;
		$this->idCard->travel_document_issue_by = @$this->passport->issue_place;
		$this->idCard->travel_document_issue_date = @$this->passport->issue_date;
		$this->idCard->travel_document_valid_date = @$this->passport->issue_expiry;
		$this->idCard->travel_document_country = @$this->passport->country_code;
		
		$this->idCard->passport_no = @$this->passport->passport_no;
		$this->idCard->passport_issue = @$this->passport->issue_date;
		$this->idCard->passport_expiry = @$this->passport->issue_expiry;
		$this->idCard->passport_place = @$this->passport->issue_place;
		$this->idCard->passport_authority = @$this->passport->issue_place;
		$this->idCard->passport_issue_by = @$this->passport->issue_place;
		
		
		
		return $this->idCard;
	}
	
	public function getFilled(){
		$forms = array();
		$f = explode(',', $this->idCard->fill_form);
		$base_category = $this->CI->config->item('base_category', 'my_options');
		foreach($this->rTablePdf as $key=>$val){
			$val->fill = in_array($val->id, $f); 
			$forms[$base_category[$val->base_category]][] = $val;
		}
		return $forms;
	}
	

	
}
// END Pager Class

/* End of file Fillform.php */
/* Location: ./application/libraries/Fillform.php */